<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        button{
            background: lightblue;
            color:#fff;
        }
        .offset{
            border: 1px solid #333;
            height: 200px;
            width: 500px;
            padding-top: 200px;
            text-align: center;
            
        }
    </style>
</head>
<body>
    <div id="app">
        <!-- once 只能点击一次 -->
        <button v-on:click.once="add(10)">加岁</button>
        <button v-on:click="subscribe(5)">减岁</button>
        <p>年龄：{{ age }}</p>
        <div class="offset" v-on:mousemove="updateXY">
            当前鼠标坐标：{{x}} &times;
            {{y}}
            <div v-on:mousemove="stopMoving">js阻止冒泡</div>
            <div v-on:mousemove.stop="">vue 阻止冒泡</div>
        </div>

        <div>
            <!-- prevent会阻止跳转 -->
            <a v-on:click.prevent="alert" href="http://www.baidu.com">click me</a>
        </div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <script>
        new Vue({
            el:"#app",
            data:{
                age:30,
                x:0,
                y:0
            },
            methods:{
                add: function(n){
                    this.age = this.age + n;
                },
                subscribe: function(n){
                    this.age -= n
                },
                updateXY: function(e){
                    // console.log(e);
                    this.x = e.offsetX;
                    this.y = e.offsetY;
                },
                stopMoving: function(event){
                    event.stopPropagation();
                    
                },
                alert:function(){
                    alert("跳转吗？");
                }
            }
        })
    </script>
</body>
</html>